package leetcode.biweekly.week102;

//Solution2Test
public class Solution2 {

	public long[] findPrefixScore(int[] nums) {
		int n = nums.length;
		long[] d = new long[n];
		long max = 0;
		for (int i = 0; i < n; i++) {
			int num = nums[i];
			max = Math.max(max, num);
			d[i] = num + max;
		}
		long[] ans = new long[n];
		ans[0] = d[0];
		for (int i = 1; i < n; i++) {
			ans[i] = ans[i - 1] + d[i];
		}
		return ans;
	}
}
